﻿using System;
using System.ServiceProcess;

namespace CodeflowsHost
{
    class Program
    {
        static void Main(string[] args)
        {
            if(!ShouldRunInConsole(args))
            {
                ServiceBase.Run(new ServiceBase[]
                                    {
                                        new CodeflowWorkerHost(), 
                                        new CodeflowsDashboardHost(), 
                                        new CodeflowsRecoveryService()
                                    });
                return;
            }

            new CodeflowWorkerHost().Start();
            new CodeflowsDashboardHost().Start();
            new CodeflowsRecoveryService().Start();

            Console.WriteLine("Codeflows host started...");
            Console.ReadLine();
        }

        static bool ShouldRunInConsole(string[] args)
        {
            if (args.Length == 0)
                return false;

            return args[0] == "c";
        }
    }
}
